package zhouzhouyongche.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zhouzhouyongche.dao.CityDao;
import zhouzhouyongche.dao.SiteDao;
import zhouzhouyongche.model.City;
import zhouzhouyongche.model.Site;
import zhouzhouyongche.service.SiteService;

@Service
public class SiteServiceImpl implements SiteService {

	@Autowired
	private CityDao cityDao;
	@Autowired
	private SiteDao siteDao;
	
	@Override
	public List getSites(int cityId) {
		return cityDao.getSites(cityId);
	}

	@Override
	public void addSite(int cityId, String siteName) {
		City city = cityDao.get(cityId);
		Site s = new Site();
		s.setSiteName(siteName);
		
		city.getSiteList().add(s);
		siteDao.save(s);
		cityDao.update(city);
	}

	
}
